package com.ruoyi.settled.controller;

import com.ruoyi.settled.domain.PaymentRequest;
import com.ruoyi.settled.service.AlipayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/alipay")
public class AlipayController {

    private final AlipayService alipayService;

    @Autowired
    public AlipayController(AlipayService alipayService) {
        this.alipayService = alipayService;
    }

    @PostMapping("/create")
    public String createPayment(@RequestBody PaymentRequest request) {
        return alipayService.createPayment(request.getOutTradeNo(), request.getTotalAmount(), request.getSubject());
    }
}